package com.jiuyun.servlet;

import com.google.gson.Gson;
import com.jiuyun.dao.HeroDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/auto")
public class AutoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Gson gson = new Gson();
        HeroDao dao = new HeroDao();
        List list =dao.getPage();
        String t = gson.toJson(list);
        request.setAttribute("list",t);
        request.setAttribute("info","方特");

        request.getRequestDispatcher("/index.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request,response);
    }
}
